﻿<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:me="clr-namespace:SPIWareMVVM.ViewModels" 
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:controls="clr-namespace:SPIWareMVVM.Views"
        xmlns:converters="clr-namespace:SPIWareMVVM.Views.Conversions"
        xmlns:reports="clr-namespace:SPIWareMVVM.Reports"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" 
        xmlns:ee="http://schemas.microsoft.com/expression/2010/effects" mc:Ignorable="d" x:Class="SPIWareMVVM.Views.Window1"
        x:Name="WindowMain" Icon="..\SPILogo.ico" Title="SPIWare " 
        Height="768" Width="1024">
    <Window.Resources>
        <ObjectDataProvider x:Key="applicationVM" ObjectType="{x:Type me:ApplicationViewModel}"/>
        <converters:BoolToVisibilityConverter x:Key="boolToVis" />
        <converters:CanUserSeeConverter x:Key="canUserSeeMe"/>
    </Window.Resources>

    <DockPanel DataContext="{Binding Source={StaticResource applicationVM}}">
        <ribbon:Ribbon DockPanel.Dock="Top" x:Name="myRibbon" DataContext="{Binding Source={StaticResource applicationVM}}" Background="#FFDFE9F5">
            <ribbon:Ribbon.QuickAccessToolBar>
                <ribbon:RibbonQuickAccessToolBar>
                    <TextBlock Text="{Binding ApplicationTitle, Mode=OneTime, Source={StaticResource applicationVM}}"/>
                    <StackPanel Orientation="Horizontal">
                        <ribbon:RibbonSeparator/>
                        <TextBlock Text="{Binding SelectedUser.LastName}"/>
                        <TextBlock Text=", "/>
                        <TextBlock Text="{Binding SelectedUser.FirstName}"/>
                        <ribbon:RibbonSeparator/>
                    </StackPanel>
                    <ribbon:RibbonButton SmallImageSource="..\Images\Save.png" ToolTip="Save All Work"
                                         Command="{Binding SaveCommand}"
                                         CommandParameter="{Binding ElementName=customersList}"/>
                </ribbon:RibbonQuickAccessToolBar>
            </ribbon:Ribbon.QuickAccessToolBar>
            <ribbon:Ribbon.ApplicationMenu>
                <ribbon:RibbonApplicationMenu>
                    <ribbon:RibbonApplicationMenuItem>
                        <TextBlock Text="{Binding DatabaseConfigString}" Height="48"/>
                    </ribbon:RibbonApplicationMenuItem>
                </ribbon:RibbonApplicationMenu>
            </ribbon:Ribbon.ApplicationMenu>

            <ribbon:RibbonTab x:Name="CustomerTab" Header="Customers">
                <ribbon:RibbonGroup x:Name="grpCustomerList" Header="Lists" >
                    <!--Visibility="{Binding IsUserLoggedIn, Converter={StaticResource boolToVis}}">-->
                    <ribbon:RibbonButton x:Name="btnCustomerList" LargeImageSource="..\Images\Customer.png" Label="" ToolTip="List All Customers"
                        Command="{Binding ShowCustomerListCommand}"
                        CommandParameter="{Binding ElementName=customersList}"/>
                    <ribbon:RibbonButton x:Name="btnCustomerWO" SmallImageSource="..\Images\WorkOrder.png" Label="Work Order" ToolTip="Display Selected Customers' Work Orders"
                        Command="{Binding ShowCustomerWOListCommand}"
                        CommandParameter="{Binding ElementName=workOrdersList}"
                        IsEnabled="False" />
                    <ribbon:RibbonButton x:Name="btnCustomerParts" SmallImageSource="..\Images\DuraShell.png" Label="Parts" ToolTip="Display Selected Customers' Associated Parts"
                        Command="{Binding ShowCustomerMaterialListCommand}"
                        CommandParameter="{Binding ElementName=materialsList}"
                        IsEnabled="False"/>
                    <ribbon:RibbonButton x:Name="btnNewContact" SmallImageSource="..\Images\AddContact64.png" Label="New Contact" ToolTip="Create a new contact for the selected Customer"
                        Command="{Binding AddNewContactCommand}"
                        CommandParameter="{Binding ElementName=customersList}"
                        IsEnabled="False"/>
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup x:Name="grpCustomerActions" Header="Actions" >
                    <!--Visibility="{Binding IsUserLoggedIn, Converter={StaticResource boolToVis}}">-->
                    <ribbon:RibbonButton x:Name="btnActions" LargeImageSource="..\Images\Actions.png" Label="" ToolTip="Use these Commands to enact activity on Selected items"
                    Click="btnActions_Click" />
                    <ribbon:RibbonButton x:Name="btnNewCustomer" SmallImageSource="..\Images\AddCustomer.png" Label="New Customer" ToolTip="Create a New Customer"
                                         Command="{Binding AddNewCustomerCommand}"
                                         CommandParameter="{Binding ElementName=customersList}"/>
                    <ribbon:RibbonButton x:Name="btnNewWO" SmallImageSource="..\Images\AddWorkOrder.png" Label="New Work Order" ToolTip="Create a New Work Order for the Selected Customer"
                                         Command="{Binding AddNewWorkOrderCommand}"
                                         CommandParameter="{Binding ElementName=workOrdersList}"/>
                    <ribbon:RibbonButton x:Name="btnCTabNewMaterial" SmallImageSource="..\Images\AddMaterials48.png" Label="New Part" ToolTip="Create a New Part Record"
                                         Command="{Binding AddNewPartCommand}"
                                         CommandParameter="{Binding ElementName=materialsList}"/>
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup x:Name="grpUsers" Header="User Maintenance" IsEnabled="False" >
                    <!--Visibility="{Binding IsUserLoggedIn, Converter={StaticResource boolToVis}}">-->
                    <ribbon:RibbonButton x:Name="btnUserList" LargeImageSource="..\Images\Users64.png" Label="List" ToolTip="List Users and Operators"/>
                    <ribbon:RibbonButton x:Name="btnNewUser" SmallImageSource="..\Images\AddUser32.png" Label="New User"  ToolTip="Create a new User or Operator"/>
                </ribbon:RibbonGroup>
            </ribbon:RibbonTab>
            <ribbon:RibbonTab x:Name="WorkOrderTab" Header="Work Orders" d:IsHidden="True" >
                <!--Visibility="{Binding IsUserLoggedIn, Converter={StaticResource boolToVis}}">-->
                <ribbon:RibbonGroup x:Name="grpWorkOrderList" Header="Lists">
                    <ribbon:RibbonButton x:Name="btnWorkOrders" LargeImageSource="..\Images\WorkOrder.png" Label="" ToolTip="List All Work Orders"
                        Command="{Binding ShowWorkOrderListCommand}"
                        CommandParameter="{Binding ElementName=workOrdersList}"/>
                    <ribbon:RibbonButton x:Name="btnNewWorkOrder" SmallImageSource="..\Images\AddWorkOrder.png" Label="New Work Order" ToolTip="Create a New Work Order"
                                         Command="{Binding AddNewWorkOrderCommand}"
                                         CommandParameter="{Binding ElementName=workOrdersList}"/>
                    <ribbon:RibbonButton x:Name="btnCompleteWorkOrder" SmallImageSource="..\Images\CompleteWO48.png" Label="Complete Work Order" ToolTip="Mark the Selected Work Order as Complete"
                                         Command="{Binding CompleteWOCommand}"
                                         CommandParameter="{Binding ElementName=workOrdersList}"/>
                    <ribbon:RibbonButton x:Name="btnWODeliveries" SmallImageSource="..\Images\Delivery48.png" Label="Work Order Deliveries" ToolTip="List Selected Work Order Deliveries"
                                         Command="{Binding ShowWODeliveriesListCommand}"
                                         CommandParameter="{Binding ElementName=deliveryList}"
                                         IsEnabled="False"/>
                    <ribbon:RibbonButton x:Name="btnPrintWO" SmallImageSource="..\Images\WorkOrder.png" Label="" ToolTip="Print Selected Work Orders"
                                         Command="{Binding PrintReportsCommand}"
                                         CommandParameter="{Binding ElementName=WindowMain}"/>
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup x:Name="grpDelivery" Header="Delivery" IsEnabled="False" >
                    <ribbon:RibbonButton DockPanel.Dock="Left" x:Name="btnDelivery" LargeImageSource="..\Images\Delivery64.png" Label="" ToolTip="List All Delivery Records"
                                         Command="{Binding ShowDeliveryListCommand}"
                                         CommandParameter="{Binding ElementName=deliveryList}"/>
                    <ribbon:RibbonButton DockPanel.Dock="Top" x:Name="btnNewDelivery" SmallImageSource="..\Images\Delivery48.png" Label="New Delivery" ToolTip="Create a New Delivery Record" />
                    <ribbon:RibbonComboBox x:Name="cboDeliveryDate"/>
                </ribbon:RibbonGroup>
            </ribbon:RibbonTab>
            <ribbon:RibbonTab x:Name="ProductionTab" Header="Production" d:IsHidden="True" 
                              >
                <!--Visibility="{Binding IsUserLoggedIn, Converter={StaticResource boolToVis}}">-->
                <ribbon:RibbonGroup x:Name="grpProduction" Header="Production">
                    <ribbon:RibbonButton x:Name="btnProductionList" LargeImageSource="..\Images\Production.png" Label="" ToolTip="List All Production Records"
                                         Command="{Binding ShowProductionListCommand}"
                                         CommandParameter="{Binding ElementName=productionsList}"/>
                    <ribbon:RibbonButton x:Name="btnNewRun" SmallImageSource="..\Images\ProductionRun.png" Label="New Production" ToolTip="Create a New Production Record"
                                         Command="{Binding AddNewProductionCommand}"
                                         CommandParameter="{Binding ElementName=productionsList}"/>
                    <ribbon:RibbonButton x:Name="btnNewDowntime" SmallImageSource="..\Images\DownTime24.png" Label="New Downtime" ToolTip="Create a New Downtime Record" IsEnabled="False"/>
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup x:Name="grpFilters" Header="Filters">
                    <ribbon:RibbonButton x:Name="btnFilters" LargeImageSource="..\Images\Funnel64.png" Label="" ToolTip="" />
                    <ComboBox HorizontalAlignment="Right" SelectionChanged="RunDateSelectionChanged" ToolTip="Select the Run Date to Filter on"
                              ItemsSource="{Binding Path=RunDates, Source={StaticResource applicationVM}}" x:Name="cboRunDates"/>

                    <ribbon:RibbonComboBox ToolTip="Select the Shift to Filter on" IsEnabled="False" >
                        <ribbon:RibbonGallery x:Name="cboShift"/>
                    </ribbon:RibbonComboBox>
                    <ribbon:RibbonButton x:Name="btnRemoveFilters" SmallImageSource="..\Images\RemoveFilter24.png" Label="Remove Filters" ToolTip="Remove All Filters" IsEnabled="False"/>
                    <!--<ribbon:RibbonComboBox ToolTip="Select the Customer to Filter on" IsEnabled="False">
                        <ribbon:RibbonGallery x:Name="cboCustomers" />
                    </ribbon:RibbonComboBox>-->
                </ribbon:RibbonGroup>
            </ribbon:RibbonTab>
            <ribbon:RibbonTab x:Name="MaterialsTab" Header="Parts and Materials" 
                              >
                <!--Visibility="{Binding IsUserLoggedIn, Converter={StaticResource boolToVis}, ConverterParameter={StaticResource applicationVM}}">-->
                <!--<ribbon:RibbonTab x:Name="MaterialsTab" Header="Materials">
                <ribbon:RibbonTab.Visibility>
                    <Binding ElementName="Visibility" Path="canUserSeeMe">
                        <Binding.ConverterParameter>
                            <x:Array Type="{x:Type sys:Object}">
                                <x:Static Member="{StaticResource applicationVM}"/>
                                <sys:String>MaterialsTab</sys:String>
                            </x:Array>
                        </Binding.ConverterParameter>
                    </Binding>
                </ribbon:RibbonTab.Visibility>-->
                <ribbon:RibbonGroup x:Name="grpMaterialsList" Header="Parts">
                    <ribbon:RibbonButton x:Name="btnMaterials" LargeImageSource="..\Images\DuraShell.png" Label="" ToolTip="List All Materials"
                                         Command="{Binding ShowMaterialsListCommand}"
                                         CommandParameter="{Binding ElementName=materialsList}"/>
                    <ribbon:RibbonButton x:Name="btnNewMaterial" SmallImageSource="..\Images\AddMaterials48.png" Label="New Part" ToolTip="Create a New Part Record"
                                         Command="{Binding AddNewPartCommand}"
                                         CommandParameter="{Binding ElementName=materialsList}"/>
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup x:Name="grpMachineList" Header="Press Machines">
                    <ribbon:RibbonButton x:Name="btnMachines" LargeImageSource="..\Images\Machine64.png" Label="" ToolTip="List All Press Machines"
                                         Command="{Binding ShowPressMachineListCommand}"
                                         CommandParameter="{Binding ElementName=pressMachinesList}"/>
                    <ribbon:RibbonButton x:Name="btnNewMachine" SmallImageSource="..\Images\AddMachine48.png" Label="New Press Machine" ToolTip="Create a New Press Machine"
                                         Command="{Binding AddNewPressMachineCommand}"
                                         CommandParameter="{Binding ElementName=pressMachinesList}" />
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup x:Name="grpCommissions" Header="Commissions" IsEnabled="False">
                    <ribbon:RibbonButton x:Name="btnCommissions" LargeImageSource="..\Images\Commissions64.png" Label="" ToolTip="List All Commission Records"
                                         Command="{Binding ShowCommissionsListCommand}"
                                         CommandParameter="{Binding ElementName=commissionsList}"/>
                    <ribbon:RibbonButton x:Name="btnNewCommission" SmallImageSource="..\Images\AddCommission48.png" Label="New Commission" ToolTip="Create a New Commission Record"/>
                </ribbon:RibbonGroup>
            </ribbon:RibbonTab>
            <ribbon:RibbonTab x:Name="ReportsTab" Header="Printed Reports">
                <ribbon:RibbonGroup x:Name="grpWorkOrderReports" Header="Work Orders">
                    <!--<ribbon:RibbonButton x:Name="btnWOInProgress" Label="In Progress" ToolTip="Print a list of Current Work Orders In Production"
                                         Command="{Binding PrintReportsCommand}"
                                         CommandParameter="{Binding ElementName=btnWOInProgress}"/>-->
                    <ribbon:RibbonButton x:Name="btnPrintWO2" Label="Selected Work Order" ToolTip="Print Currently Selected Item"
                                         Command="{Binding PrintReportsCommand}"
                                         CommandParameter="{Binding ElementName=WindowMain}"/>
                    <ribbon:RibbonButton x:Name="btnWOSummary" Label="Summary" ToolTip="Print the Work Order Summary Report"
                                         Command="{Binding PrintReportsCommand}"
                                         CommandParameter="{Binding ElementName=btnWOSummary}"/>
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup x:Name="grp24HourReports" Header="24 Hour Production">
                    <!--<ribbon:RibbonButton x:Name="btn24HourProductionLog" Label="Log" ToolTip="Print the 24 Hour Production Log Report"
                                         Command="{Binding PrintReportsCommand}"
                                         CommandParameter="{Binding ElementName=btn24HourProductionLog}"/>
                    <ribbon:RibbonButton x:Name="btn24HourProductionSummary" Label="Summary" ToolTip="Print the 24 Hour Production Summary Report"
                                         Command="{Binding PrintReportsCommand}"
                                         CommandParameter="{Binding ElementName=btn24HourProductionSummary}"/>-->
                </ribbon:RibbonGroup>
            </ribbon:RibbonTab>
        </ribbon:Ribbon>
        <controls:CustomerList x:Name="customersList" Visibility="Collapsed" />
        <controls:WorkOrderList x:Name="workOrdersList" Visibility="Collapsed"/>
        <controls:MaterialList x:Name="materialsList" Visibility="Collapsed"/>
        <controls:CommissionList x:Name="commissionsList" Visibility="Collapsed"/>
        <controls:DeliveryList x:Name="deliveryList" Visibility="Collapsed"/>
        <controls:PressMachineList x:Name="pressMachinesList" Visibility="Collapsed"/>
        <controls:ProductionList x:Name="productionsList" Visibility="Collapsed"/>
        <!-- 96 pixels per inch
        8.5 x 11 == 624 x 864 1" margins
            == 720 x 960 .5" margins-->
        <!-- Height="864" Width="624"-->
        <reports:WorkOrderReport x:Name="workOrderReport" Visibility="Collapsed" HorizontalAlignment="Left" Height="1056" Width="816"/>
    </DockPanel>
</Window>
